package com.leo.java8.lambda;


public class NewFeaturesTester1 {

	public static void main(String[] args) {
		NewFeaturesTester1 tester = new NewFeaturesTester1();

		MathOperation addition = (int a, int b) -> a + b;

		MathOperation subtraction = (a, b) -> a - b;

		MathOperation multiplication = (int a, int b) -> {
			return a * b;
		};

		MathOperation division = (int a, int b) -> a / b;

		System.out.println("10 + 5 = " + tester.operate(10, 5, addition));

		System.out.println("10 - 5 = " + tester.operate(10, 5, subtraction));

		System.out.println("10 * 5 = " + tester.operate(10, 5, multiplication));

		System.out.println("10 / 5 = " + tester.operate(10, 5, division));

		GreetingService greetService1 = message -> System.out.println("Hello " + message);

		GreetingService greetService2 = (message) -> System.out.println("Hello " + message);

		greetService1.sayMessage("Shiyanlou");
		greetService2.sayMessage("Classmate");

	}

	interface MathOperation {
		int opration(int a, int b);
	}

	interface GreetingService {
		void sayMessage(String message);
	}

	private int operate(int a, int b, MathOperation mathOperation) {
		return mathOperation.opration(a, b);
	}

}